*** Replication                                                                                             
*** Deciding how to decide on public goods provision:  The role of instrumental vs. intrinsic motives                                                                
*** Author: blinded                                        
*** 01. Apr. 2021 

***************
*** Dataset ***
***************

use "~\PG_DataFile\pg_data.dta", clear
cd "~\PG_DataFile"
log using "~\PG_DataFile\pg_log.log"

**************
*** Coding ***
**************

*** Treatment conditions
sort sessionid period group subject
recode treatment 1=2 2=3 3=1, gen(treatment2)
drop treatment
rename treatment2 treatment
label define treatment_lb 2 "Gr.Major." 3 "Gr.Benefit" 1 "No Info" 
label values treatment treatment_lb
label var treatment "Treatment"

*** Ind. utility from PG (Dummy, 1=pos., 0=neg.)
gen     ind_util_pos = .
replace ind_util_pos = 1 if  netpay== 8
replace ind_util_pos = 1 if  netpay== 3
replace ind_util_pos = 0 if  netpay==-3
replace ind_util_pos = 0 if  netpay==-8
label var ind_util_pos "Ind. Utility"
label define ind_util_pos_lb 1 "Ind.U. Pos." 0 "Ind.U. Neg." 
label values ind_util_pos ind_util_pos_lb

*** Group majority (Dummy, 1= pro PG, 0 = contra PG)
gen gr_maj_pos = .
replace gr_maj_pos = 1 if majority==1
replace gr_maj_pos = 0 if majority==0
label var gr_maj_pos "Group Majority"
label define gr_maj_pos_lb 1 "Pro PG" 0 "Contra PG" 
label values gr_maj_pos gr_maj_pos_lb

*** Group Benefit (Dummy, 1=pos., 0=neg.)
gen     gr_util_pos = .
replace gr_util_pos = 1 if  networth==  3
replace gr_util_pos = 1 if  networth==  2
replace gr_util_pos = 0 if  networth== -2
replace gr_util_pos = 0 if  networth== -3
label var gr_util_pos "Group Benefit"
label define gr_util_pos_lb 1 "Pos." 0 "Neg." 
label values gr_util_pos gr_util_pos_lb

*** Rational procedural choice MV vs. Delegation (for T2 and T3)
gen rat_MV = .
replace rat_MV = 1 if gr_maj_pos==1 & ind_util_pos==1 & treatment==2
replace rat_MV = 1 if gr_maj_pos==0 & ind_util_pos==0 & treatment==2
replace rat_MV = 0 if gr_maj_pos==1 & ind_util_pos==0 & treatment==2
replace rat_MV = 0 if gr_maj_pos==0 & ind_util_pos==1 & treatment==2
replace rat_MV = 0 if gr_util_pos==1 & ind_util_pos==1 & treatment==3
replace rat_MV = 0 if gr_util_pos==0 & ind_util_pos==0 & treatment==3
replace rat_MV = 1 if gr_util_pos==1 & ind_util_pos==0 & treatment==3
replace rat_MV = 1 if gr_util_pos==0 & ind_util_pos==1 & treatment==3
label var rat_MV "Rat. procedure choice"
label define rat_MV_lb 1 "MV" 0 "Delegate" 
label values rat_MV rat_MV_lb

*** Rational procedural choice MV vs. Delegation (by Treatment) [PLACEBO for T1 & T2]
gen rat_MVp1 = .
replace rat_MVp1 = 1 if gr_maj_pos==1 & ind_util_pos==1 & treatment==2
replace rat_MVp1 = 1 if gr_maj_pos==0 & ind_util_pos==0 & treatment==2
replace rat_MVp1 = 0 if gr_maj_pos==1 & ind_util_pos==0 & treatment==2
replace rat_MVp1 = 0 if gr_maj_pos==0 & ind_util_pos==1 & treatment==2
replace rat_MVp1 = 1 if gr_maj_pos==1 & ind_util_pos==1 & treatment==1
replace rat_MVp1 = 1 if gr_maj_pos==0 & ind_util_pos==0 & treatment==1
replace rat_MVp1 = 0 if gr_maj_pos==1 & ind_util_pos==0 & treatment==1
replace rat_MVp1 = 0 if gr_maj_pos==0 & ind_util_pos==1 & treatment==1
label var rat_MVp1 "Rat. procedure choice"
label define rat_MVp1_lb 1 "MV" 0 "Delegate" 
label values rat_MVp1 rat_MVp1_lb

*** Rational procedural choice MV vs. Delegation (by Treatment) [PLACEBO for T1 & T3]
gen rat_MVp2 = .
replace rat_MVp2 = 0 if gr_util_pos==1 & ind_util_pos==1 & treatment==3
replace rat_MVp2 = 0 if gr_util_pos==0 & ind_util_pos==0 & treatment==3
replace rat_MVp2 = 1 if gr_util_pos==1 & ind_util_pos==0 & treatment==3
replace rat_MVp2 = 1 if gr_util_pos==0 & ind_util_pos==1 & treatment==3
replace rat_MVp2 = 0 if gr_util_pos==1 & ind_util_pos==1 & treatment==1
replace rat_MVp2 = 0 if gr_util_pos==0 & ind_util_pos==0 & treatment==1
replace rat_MVp2 = 1 if gr_util_pos==1 & ind_util_pos==0 & treatment==1
replace rat_MVp2 = 1 if gr_util_pos==0 & ind_util_pos==1 & treatment==1
label var rat_MVp2 "Rat. procedure choice"
label define rat_MVp2_lb 1 "MV" 0 "Delegate" 
label values rat_MVp2 rat_MVp2_lb

*** Rational procedural choice: EU(MV)
gen     rat_MV_cat = .
* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_cat = (1-2/3)*netpay     if gr_maj_pos==1  & ind_util_pos==1 & treatment==2
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_cat = (-1)*1/3*netpay   	if gr_maj_pos==0  & ind_util_pos==0 & treatment==2
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_cat = (1-0.5)*netpay     if gr_maj_pos==1  & ind_util_pos==0 & treatment==2
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_cat = (-1)*0.5*netpay 	if gr_maj_pos==0  & ind_util_pos==1 & treatment==2

* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_cat = 2/3*netpay     	if gr_util_pos==0  & ind_util_pos==1 & treatment==3
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_cat = (1/3-1)*netpay   	if gr_util_pos==1  & ind_util_pos==0 & treatment==3
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_cat = 1/4*netpay 		if gr_util_pos==0  & ind_util_pos==0 & treatment==3
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_cat = (3/4-1)*netpay 	if gr_util_pos==1  & ind_util_pos==1 & treatment==3


*** Rational procedural choice: EU(MV) for T2 and T3 [PLACEBO T1 & T2]
gen     rat_MV_catp1 = .
* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_catp1 = (1-2/3)*netpay     if gr_maj_pos==1  & ind_util_pos==1 & treatment==2
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_catp1 = (-1)*1/3*netpay   	if gr_maj_pos==0  & ind_util_pos==0 & treatment==2
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_catp1 = (1-0.5)*netpay     if gr_maj_pos==1  & ind_util_pos==0 & treatment==2
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_catp1 = (-1)*0.5*netpay 	if gr_maj_pos==0  & ind_util_pos==1 & treatment==2
* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_catp1 = (1-2/3)*netpay     if gr_maj_pos==1  & ind_util_pos==1 & treatment==1
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_catp1 = (-1)*1/3*netpay   	if gr_maj_pos==0  & ind_util_pos==0 & treatment==1
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_catp1 = (1-0.5)*netpay     if gr_maj_pos==1  & ind_util_pos==0 & treatment==1
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_catp1 = (-1)*0.5*netpay 	if gr_maj_pos==0  & ind_util_pos==1 & treatment==1

*** Rational procedural choice: EU(MV) for T2 and T3 [PLACEBO T1 & T3]
gen     rat_MV_catp2 = .
* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_catp2 = 2/3*netpay     	if gr_util_pos==0  & ind_util_pos==1 & treatment==3
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_catp2 = (1/3-1)*netpay   	if gr_util_pos==1  & ind_util_pos==0 & treatment==3
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_catp2 = 1/4*netpay 		if gr_util_pos==0  & ind_util_pos==0 & treatment==3
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_catp2 = (3/4-1)*netpay 	if gr_util_pos==1  & ind_util_pos==1 & treatment==3
* Netpay is positive, and MV makes it more likely to get it --> expected net gain from MV positive
replace rat_MV_catp2 = 2/3*netpay     	if gr_util_pos==0  & ind_util_pos==1 & treatment==1
* Netpay is negative, and MV makes it more likely to avoid it --> expected net gain from MV positive
replace rat_MV_catp2 = (1/3-1)*netpay   	if gr_util_pos==1  & ind_util_pos==0 & treatment==1
* Netpay is negative and MV makes it more likely to suffer from it --> expected net gain from MV negative
replace rat_MV_catp2 = 1/4*netpay 		if gr_util_pos==0  & ind_util_pos==0 & treatment==1
* Netpay is positive and MV makes it more likely to miss it --> expected net gain from MV negative
replace rat_MV_catp2 = (3/4-1)*netpay 	if gr_util_pos==1  & ind_util_pos==1 & treatment==1


*****************
**** Figure 1 ***
*****************

tsset id period
fvset base 1 treatment
xtlogit decisionprocedure               i.treatment     i.period                , re vce(robust)
est store m1
margins  treatment
marginsplot,  ytitle("Pr(MV)") recast(scatter)
graph save fig1.gph, replace

*********************
**** Figure 2a/b ****
*********************

**** DUMMY Group Majority & Benefit Treatments: Rational prediction of procedrual choice
xtlogit decisionprocedure i.rat_MV        i.period if treatment!=1 , re vce(robust)
est store m2a 
margins  rat_MV
marginsplot,  yline(.6361708, lpattern(solid)) yline(.575639 , lpattern(dash)) yline(.6967027, lpattern(dash)) ytitle("Pr(MV)") xtitle(" ")  title("A")
graph save fig2a.gph, replace

**** METRIC Group Majority & Benefit Treatments: Rational prediction of procedrual choice 
xtlogit decisionprocedure c.rat_MV_cat        i.period if treatment!=1 , re vce(robust)
est store m2b
margins, at(rat_MV_cat=(-4 -2 -1.5 -.75 1 2))  
marginsplot, yline(.6361708, lpattern(solid)) yline(.575639 , lpattern(dash)) yline(.6967027, lpattern(dash)) ytitle("Pr(MV)") xtitle("EU(MV)") title("B")
graph save fig2b.gph, replace

graph combine fig2a.gph fig2b.gph, ycommon xsize(6) ysize(3)

*********************
**** Figure 3a/b  ***
*********************

**** DUMMY Group Majority Treatment only: IA 
xtlogit decisionprocedure i.gr_maj_pos##i.ind_util_pos i.period if treatment==2 , re vce(robust)
est store m3a
margins  gr_maj_pos#i.ind_util_pos 
marginsplot,  yline(.6361708, lpattern(solid)) yline(.575639 , lpattern(dash)) yline(.6967027, lpattern(dash)) ytitle("Pr(MV)") title("A")
graph save fig3a.gph, replace

*** DUMMY Group Benefit Treatment only: IA
xtlogit decisionprocedure i.gr_util_pos##i.ind_util_pos i.period if treatment==3 , re vce(robust)
est store m3b
margins  gr_util_pos#i.ind_util_pos
marginsplot, yline(.6361708, lpattern(solid)) yline(.575639 , lpattern(dash)) yline(.6967027, lpattern(dash)) ytitle("Pr(MV)")  title("B")
graph save fig3b.gph, replace

graph combine fig3a.gph fig3b.gph, ycommon xsize(6) ysize(3)

*****************
*** Table A6  ***
*****************

esttab m1 m2a m2b m3a m3b  using tab_A6.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalars("ll Log pseudolik.") aic bic nogaps replace label  nobaselevels


***********************
**** PLACEBO TESTS  ***
***********************

*** Treatment dummies
tab treatment, gen(treat_dum)

*** Subsample Treatment 1 and 2
gen treat12 = 0
replace treat12 = 1 if treatment==1
replace treat12 = 1 if treatment==2

*** Subsample Treatment 1 and 3
gen treat13 = 0
replace treat13 = 1 if treatment==1
replace treat13 = 1 if treatment==3

tsset id period
fvset base 1 treatment

*****************
*** Figure A4 ***
*****************

* A4a Model 2a (T2 vs T1) 
xtlogit decisionprocedure i.rat_MVp1##i.treat_dum2        i.period if treat12==1 , re vce(robust)
est store m2a_p1 
margins i.rat_MVp1, dydx(i.treat_dum2) post
marginsplot, yline(0)  ytitle("Effects on Pr(MV)") xtitle(" ") title("A") 
graph save fig4a.gph, replace
* Model 2b (T2 vs T1)
xtlogit decisionprocedure c.rat_MV_catp1##i.treat_dum2       i.period if treat12==1 , re vce(robust)
est store m2b_p1 
margins, dydx(treat_dum2) at(rat_MV_catp1=(-4, -1.5, 1)) vsquish
marginsplot, yline(0) ytitle("Effects on Pr(MV)")  xtitle("EU(MV)") title("B")
graph save fig4b.gph, replace
graph combine fig4a.gph fig4b.gph, ycommon xsize(6) ysize(3)

*****************
*** Figure A5 ***
*****************

* A5a Model 2a (T3 vs T1) 
xtlogit decisionprocedure i.rat_MVp2##i.treat_dum3        i.period if treat13==1 , re vce(robust)
est store m2a_p2 
margins i.rat_MVp2, dydx(i.treat_dum3) post
marginsplot, yline(0) ytitle("Effects on Pr(MV)") xtitle(" ") title("A")
graph save fig5a.gph, replace
* A5b Model 2b (T3 vs T1)
xtlogit decisionprocedure c.rat_MV_catp2##i.treat_dum3       i.period if treat13==1 , re vce(robust)
est store m2b_p2 
margins, dydx(treat_dum3) at(rat_MV_catp2=(-2, -.75, 2)) vsquish
marginsplot, yline(0) ytitle("Effects on Pr(MV)")  xtitle("EU(MV)") title("B")
graph save fig5b, replace
graph combine fig5a.gph fig5b.gph, ycommon xsize(6) ysize(3)


*****************
*** Figure A6 ***
*****************

* A6a1
xtlogit decisionprocedure i.gr_maj_pos##i.ind_util_pos##i.treat_dum2 i.period if treat12==1 , re vce(robust)
est store m3a_p 
margins gr_maj_pos, dydx(ind_util_pos) at(treat_dum2==1) post
marginsplot, yline(0) ytitle("Effects on Pr(MV)") title("A1")
graph save fig6a1.gph, replace
* A6a2
xtlogit decisionprocedure i.gr_maj_pos##i.ind_util_pos##i.treat_dum2 i.period if treat12==1 , re vce(robust)
margins gr_maj_pos, dydx(ind_util_pos) at(treat_dum2==0) post
marginsplot, yline(0) ytitle("Effects on Pr(MV)") title("A2")
graph save fig6a2.gph, replace
graph combine fig6a1.gph fig6a2.gph, ycommon xsize(6) ysize(3)

*****************
*** Figure A7 ***
*****************

* A7b1
xtlogit decisionprocedure i.gr_util_pos##i.ind_util_pos##i.treat_dum3 i.period if treat13==1 , re vce(robust)
est store m3b_p 
margins gr_util_pos, dydx(ind_util_pos) at(treat_dum3==1) post
marginsplot, yline(0) ytitle("Effects on Pr(MV)") title("B1")
graph save fig7b1.gph, replace
xtlogit decisionprocedure i.gr_util_pos##i.ind_util_pos##i.treat_dum3 i.period if treat13==1 , re vce(robust)
* A7b2
margins gr_util_pos, dydx(ind_util_pos) at(treat_dum3==0) post
marginsplot, yline(0) ytitle("Effects on Pr(MV)") title("B2")
graph save fig7b2.gph, replace
graph combine fig7b1.gph fig7b2.gph, ycommon xsize(6) ysize(3)

*****************
*** Table A6  ***
*****************

esttab m2a_p1 m2b_p1 m2a_p2 m2b_p2 m3a_p m3b_p using tab_A7.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalars("ll Log pseudolik.") aic bic nogaps replace label  nobaselevels

log close

